package com.core.zyyz.amc.modules.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.zyyz.amc.modules.domain.AmcProjectLibraryB;
import com.core.zyyz.amc.modules.service.AmcProjectLibraryBService;
import com.core.common.utils.poi.ExcelUtil;
import com.core.common.core.page.TableDataInfo;

/**
 * 项目库Controller
 *
 * @author lfs
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/amc/projectlibrary")
public class AmcProjectLibraryBController extends BaseController
{
    @Autowired
    private AmcProjectLibraryBService amcProjectLibraryBService;

    /**
     * 查询项目库列表
     */
    @PreAuthorize("@ss.hasPermi('amc:projectlibrary:list')")
    @GetMapping("/list")
    public TableDataInfo list(AmcProjectLibraryB amcProjectLibraryB) {
        startPage();
        List<AmcProjectLibraryB> list = amcProjectLibraryBService.selectAmcProjectLibraryBList(amcProjectLibraryB);
        return getDataTable(list);
    }

    /**
     * 导出项目库列表
     */
    @PreAuthorize("@ss.hasPermi('amc:projectlibrary:export')")
    @Log(title = "项目库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AmcProjectLibraryB amcProjectLibraryB)
    {
        List<AmcProjectLibraryB> list = amcProjectLibraryBService.selectAmcProjectLibraryBList(amcProjectLibraryB);
        ExcelUtil<AmcProjectLibraryB> util = new ExcelUtil<AmcProjectLibraryB>(AmcProjectLibraryB.class);
        util.exportExcel(response, list, "项目库数据");
    }

    /**
     * 获取项目库详细信息
     */
    @PreAuthorize("@ss.hasPermi('amc:projectlibrary:query')")
    @GetMapping(value = "/{projectLibraryId}")
    public AjaxResult getInfo(@PathVariable("projectLibraryId") String projectLibraryId)
    {
        return success(amcProjectLibraryBService.selectAmcProjectLibraryBByProjectLibraryId(projectLibraryId));
    }

    /**
     * 新增项目库
     */
    @PreAuthorize("@ss.hasPermi('amc:projectlibrary:add')")
    @Log(title = "项目库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AmcProjectLibraryB amcProjectLibraryB)
    {
        return toAjax(amcProjectLibraryBService.insertAmcProjectLibraryB(amcProjectLibraryB));
    }

    /**
     * 修改项目库
     */
    @PreAuthorize("@ss.hasPermi('amc:projectlibrary:edit')")
    @Log(title = "项目库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AmcProjectLibraryB amcProjectLibraryB)
    {
        return toAjax(amcProjectLibraryBService.updateAmcProjectLibraryB(amcProjectLibraryB));
    }

    /**
     * 删除项目库
     */
    @PreAuthorize("@ss.hasPermi('amc:projectlibrary:remove')")
    @Log(title = "项目库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{projectLibraryIds}")
    public AjaxResult remove(@PathVariable String[] projectLibraryIds)
    {
        return toAjax(amcProjectLibraryBService.deleteAmcProjectLibraryBByProjectLibraryIds(projectLibraryIds));
    }
}
